package com.yohann.designPattern.flyweight;

import java.util.HashMap;

/**
 * <p>
 * 网站工厂
 * </p>
 *
 * @author Yohann
 * @since 2021/2/8 14:23
 */
public class WebsiteFactory {
    private HashMap<String, ConcreteWebsite> pool = new HashMap<>();

    public Website getWebsiteCategory(String type) {
        if (!pool.containsKey(type)) {
            pool.put(type, new ConcreteWebsite(type));
        }

        return (Website) pool.get(type);
    }

    public int getWebsiteSize() {
        return pool.size();
    }
}